package com.david.elasticjob.config;

import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 注册中心的配置
 * @author David
 * @version V1.0
 * @Package com.david.elasticjob.config
 * @date 2021/5/4 11:29
 */
@Configuration
public class ElasticJobRegistryConfig {
    @Bean(initMethod = "init")
    public ZookeeperRegistryCenter zookeeperRegistryCenter(@Value("${job.regCenter.serverList}") String serverList,
                                                           @Value("${job.regCenter.namespace}")String nameSpace){
        ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(serverList, nameSpace);
        return new ZookeeperRegistryCenter(zookeeperConfiguration);
    }
}
